/*
Sanctions, Aid, and Voting Patterns in the United Nations General Assembly
commands for creating supplemental appendix
*/

**# Load Data and Put Data Editor Files in Working Direcotry
	/* insert your working directory here */
	use "SUNV-data.dta", clear
	version 16
	
	/*
	There are four graph editor files included with the data archive. These should
	be placed in the active working directory so that this do file can access them.
	The files are named:
	Fig1A.grec
	Fig1B.grec
	Fig2A.grec
	Fig2B.grec
	*/	
	
**# Make Global Controls
	global cvarl = "lUCDPInterConf lUCDPIntraConf latopdefense2 lVDEMv2x_polyarchy2 lunderIMF2 llnWDIGDPPCCUS2 llnWDIMilExPGDP2 llnCOWTTradeWUSPGDPWDI "     
	global cvartl = "lUCDPInterConf lUCDPIntraConf latopdefense2 lVDEMv2x_polyarchy2 lunderIMF2 lWDIGDPPCCUS2 llnWDIMilExPGDP2 lCOWTTradeWUSPGDPWDI  t" 

**# Table A (In sample summary statistics based on column 1 of table 1)
	* Rerun model
		xtreg absidealimportantdiff lEUSimpositionUS zllnGBAidTotPGDPWDIa lEUSThOnly ///
		$cvarl i.year, fe cluster(ccode2) 

	* get summary stats
		gstats tabstat absidealimportantdiff lEUSimpositionUS lSanUSTermAid lEUSthreatUS lThUSTermAid ///
		zllnGBAidTotPGDPWDIa lUCDPInterConf lUCDPIntraConf latopdefense2 lVDEMv2x_polyarchy2 ///
		lunderIMF2 llnWDIGDPPCCUS2 llnWDIMilExPGDP2 lnCOWTTradeWUSPGDPWDI t NatDisTcy lEUSUSTot ///
		if e(sample)==1, stat(n mean sd min max) col(stat)  format(%7.2g) 

**# Table B (Aid Sanctions)
	* OLS (Columns 1 and 2)	
	est clear	
	*Table B: Column 1
	xtreg absidealimportantdiff lSanUSTermAid zllnGBAidTotPGDPWDIa lother ///
	$cvarl i.year902, fe cluster(ccode2) 
	eststo m1
	vif, uncentered
		
	*Table B: Column 2
	xtreg absidealimportantdiff c.lSanUSTermAid##c.zllnGBAidTotPGDPWDIa lother ///
	$cvarl  i.year902, fe cluster(ccode2)
	eststo m2
	vif, uncentered
	
	* Make Table B 	(Columns 1 and 2)
		esttab, bic replace onecell nogap obslast ///
		keep(lSanUSTermAid zllnGBAidTotPGDPWDIa c.lSanUSTermAid#c.zllnGBAidTotPGDPWDIa lEUSThOnly lother $cvarl) ///
		order(lSanUSTermAid zllnGBAidTotPGDPWDIa c.lSanUSTermAid#c.zllnGBAidTotPGDPWDIa lEUSThOnly lother $cvarl) ///
		star(* .1 ** .05 *** .01) label  b(2) t(2) 
		
	*Table B: Column 2: Reverse Interaction for Interpretation
	xtreg absidealimportantdiff c.lNonSanUSTermAid##c.zllnGBAidTotPGDPWDIa lother ///
	$cvarl i.year902, fe cluster(ccode2)
	
	* 2SLS Model (Columns 3 and 4)
		est clear
		ivreg2 absidealimportantdiff zllnGBAidTotPGDPWDIa lother $cvarl ///
		(lSanUSTermAid = llSanUSTermAid lEUSUSTot) i.ccode2 i.year902 ///
		,  first savefprefix(first) redundant(llSanUSTermAid lEUSUSTot) ///
		endog(lSanUSTermAid) savefirst cluster(ccode2) partial(i.ccode2 i.year902)
		eststo 
			
		* Make Table B: Column 4: Second Stage Results
		esttab, bic replace onecell nogap obslast ///
		star(* .1 ** .05 *** .01) label b(2) t(2) 
		
		* Make Table B: Coumn 3: first stage results	
		esttab first*, keep(zllnGBAidTotPGDPWDIa lEUSThOnly lother $cvarl lEUSUSTot) ///
		order(zllnGBAidTotPGDPWDIa lEUSThOnly lother $cvarl lEUSUSTot) ///
		bic replace onecell nogap obslast ///
		star(* .1 ** .05 *** .01) label b(2) t(2) 

	* 2SLS Interaction Model (Columns 5, 6, 7)
		est clear
		ivreg2 absidealimportantdiff zllnGBAidTotPGDPWDIa lother $cvarl ///
		(lSanUSTermAid zlSanAidXzllnAidPGDPa = llSanUSTermAid lzlSanAidXzllnAidPGDPa ///
		lEUSUSTot zlEUSUSTotXllnAidPGDPa) i.ccode2 i.year902, first savefprefix(first) ///
		redundant(llSanUSTermAid lzlSanAidXzllnAidPGDPa lEUSUSTot zlEUSUSTotXllnAidPGDPa) ///
		endog(lSanUSTermAid zlSanAidXzllnAidPGDPa) savefirst cluster(ccode2) ///
		partial(i.ccode2 i.year902)
		eststo m1
		vif, uncentered
				
		* Make Table B: Column 7: Second Stage Results
			esttab, bic replace onecell nogap obslast ///
			order(lSanUSTermAid zllnGBAidTotPGDPWDIa zlSanAidXzllnAidPGDPa lother $cvarl) ///
			star(* .1 ** .05 *** .01) label  b(2) t(2)
			
		* Make Table B: Columns 5 and 6: first stage results	
			esttab first*, bic replace onecell nogap obslast ///
			keep(zllnGBAidTotPGDPWDIa lother $cvarl lEUSUSTot zlEUSUSTotXllnAidPGDPa) ///
			order(lSanUSTermAid zllnGBAidTotPGDPWDIa lother $cvarl lEUSUSTot zlEUSUSTotXllnAidPGDPa) ///
			star(* .1 ** .05 *** .01) label b(2) t(2) 
		
	* Table B: Column 7: Reverse Interaction for Interpretation 
			ivregress 2sls absidealimportantdiff zllnGBAidTotPGDPWDIa lother $cvarl ///
			(lNonSanUSTermAid c.lNonSanUSTermAid#c.zllnGBAidTotPGDPWDIa = llSanUSTermAid ///
			l.zlSanAidXzllnAidPGDPa lEUSUSTot zlEUSUSTotXllnAidPGDPa) ///
			i.ccode2 i.year902, first vce(cluster ccode2)

**# Plot Figure A (Aid Sanctions)
	* Re-estimate 2sls model from columns 5, 6, and 7
		ivregress 2sls absidealimportantdiff zllnGBAidTotPGDPWDIa lother $cvarl  ///
		(lSanUSTermAid c.lSanUSTermAid#c.zllnGBAidTotPGDPWDIa = llSanUSTermAid ///
		lzlSanAidXzllnAidPGDPa lEUSUSTot zlEUSUSTotXllnAidPGDPa) ///                                   
		i.ccode2 i.year902, first vce(cluster ccode2)
	* margins
		margins, at(zllnGBAidTotPGDPWDIa=(-1.5(0.05)2)) dydx(lSanUSTermAid) vsquish	
	* plot
		marginsplot, addplot(hist zllnGBAidTotPGDPWDIa if zllnGBAidTotPGDPWDIa<2 & zllnGBAidTotPGDPWDIa>-1.5, ///
		yaxis(2) yscale(alt)  xlabel(-1.5 "-1.5 Std.Dev." -1 "-1 Std.Dev." -.5 "-.5 Std.Dev." ///
		0 "Mean" 0.5 "+.5 Std.Dev." 1 "+1 Std.Dev." 1.5 "+1.5 Std.Dev." 2 "+2 Std.Dev.", ///
		labsize(small) alt) ylabel(-1(.5)1.5) color(none) blcolor(black%20)) ///
		level(95) recast(line) plot1opts(lcol(red)) legend(off) ciopt(color(red%30)) recastci(rarea) yline(0)  ///
		xtitle(Log(U.S. Aid as % of Recipient GDP), size(small)) ///
		ytitle("Marginal Effect of Sanctions", size(small)) ///
		title("Average Marginal Effect of Aid Sanctions on UNGA Vote Dissimilarity", size(small)) 
		gr_edit .yaxis2.title.style.editstyle size(small) editcopy
		gr play "Fig1A.grec"
	
**# Table C: Threat of sanctions
	* OLS (Columns 1 and 2)
	est clear
	*Table C: Column 1
	xtreg absidealimportantdiff EUSThUSNoImpDty zllnGBAidTotPGDPWDIa lEUSSanOnly ///
	$cvarl i.year902, fe cluster(ccode2) 
	eststo m1
	vif, uncentered
		
	xtreg absidealimportantdiff c.EUSThUSNoImpDty##c.zllnGBAidTotPGDPWDIa lEUSSanOnly ///
	$cvarl i.year902, fe cluster(ccode2)
	eststo m2
	vif, uncentered
			
	* Make Appendix Table C: (Columns 1 and 2)	
		esttab, bic replace onecell nogap obslast ///
		keep(EUSThUSNoImpDty zllnGBAidTotPGDPWDIa c.EUSThUSNoImpDty#c.zllnGBAidTotPGDPWDIa lEUSSanOnly $cvarl) ///
		order(EUSThUSNoImpDty zllnGBAidTotPGDPWDIa c.EUSThUSNoImpDty#c.zllnGBAidTotPGDPWDIa lEUSSanOnly $cvarl) ///
		star(* .1 ** .05 *** .01) label  b(2) t(2) 
		
	*Appendix Table C: Column 2: Reverse Interaction for Interpretation
		reg absidealimportantdiff c.lNonTNImp##c.zllnGBAidTotPGDPWDIa lEUSSanOnly ///
		$cvarl i.ccode2 i.year902, cluster(ccode2)
	
	* 2SLS Model (Columns 3 and 4)
		est clear
		ivreg2 absidealimportantdiff zllnGBAidTotPGDPWDIa lEUSSanOnly $cvarl ///
		(lEUSThUSNoImpDty = llEUSThUSNoImpDty lEUSTNITot) i.ccode2 i.year902 ///
		, first savefprefix(first) redundant(llEUSThUSNoImpDty lEUSTNITot ) ///
		endog(lEUSThUSNoImpDty) savefirst cluster(ccode2) partial(i.ccode2 i.year902)
		vif, uncentered
				
		* Make Appendix Table C: Column 4: Second Stage Results
			esttab, bic replace onecell nogap obslast ///
			star(* .1 ** .05 *** .01) label b(2) t(2)
		
		* Make Appendix Table C: Coumn 3: first stage results	
			esttab first*, bic replace onecell nogap obslast ///
			keep(zllnGBAidTotPGDPWDIa lEUSSanOnly $cvarl lEUSTNITot) ///
			order(zllnGBAidTotPGDPWDIa lEUSSanOnly $cvarl lEUSTNITot) ///
			star(* .1 ** .05 *** .01) label b(2) t(2)
		
	* 2SLS Interaction Model (Columns 5, 6, 7)
		est clear
		ivreg2 absidealimportantdiff zllnGBAidTotPGDPWDIa lEUSSanOnly $cvarl ///
		(lEUSThUSNoImpDty lThNoImpXzlAidPGDPa =  ///
		l.lEUSThUSNoImpDty l.lThNoImpXzlAidPGDPa lEUSTNITot zlTNITotXllnAidPGDPa ) ///
		i.ccode2 i.year902, first savefprefix(first) ///
		redundant(l.lEUSThUSNoImpDty l.lThNoImpXzlAidPGDPa  ///
		lEUSTNITot zlTNITotXllnAidPGDPa ) ///
		endog(lEUSThUSNoImpDty lThNoImpXzlAidPGDPa) savefirst cluster(ccode2) partial(i.ccode2 i.year902)
		eststo
		vif, uncentered
	
		* Make Table C: Column 7: Second Stage Results
		esttab, bic replace onecell nogap obslast ///
		order(lEUSThUSNoImpDty zllnGBAidTotPGDPWDIa lThNoImpXzlAidPGDPa lEUSSanOnly $cvarl) ///
		star(* .1 ** .05 *** .01) label  b(2) t(2) 
		
		
		* Make Table 1: Columns 5 and 6: first stage results	
		esttab first*, bic replace onecell nogap obslast ///
		keep(zllnGBAidTotPGDPWDIa lEUSThOnly $cvarl lEUSUSTot zlEUSUSTotXllnAidPGDPa) ///
		order(zllnGBAidTotPGDPWDIa lEUSThOnly $cvarl lEUSUSTot zlEUSUSTotXllnAidPGDPa) ///
		star(* .1 ** .05 *** .01) label  b(2) t(2) 
		
	* Table C: Column 7: Reverse Interaction for Interpretation 
		ivreg2 absidealimportantdiff zllnGBAidTotPGDPWDIa lEUSSanOnly $cvarl ///
		(lNonTNImp c.lNonTNImp#c.zllnGBAidTotPGDPWDIa  = l.lEUSThUSNoImpDty ///
		l.lThNoImpXzlAidPGDPa lEUSTNITot zlTNITotXllnAidPGDPa) i.ccode2 i.year902, ///
		cluster(ccode2) partial(i.ccode2 i.year902)
		
**# Plot Figure B (Threatened Sanctions)
	* Re-estimate 2sls model from columns 5, 6, and 7
		ivregress 2sls absidealimportantdiff zllnGBAidTotPGDPWDIa lEUSSanOnly $cvarl ///
		(lEUSThUSNoImpDty c.lEUSThUSNoImpDty#c.zllnGBAidTotPGDPWDIa  = ///
		l.lEUSThUSNoImpDty l.lThNoImpXzlAidPGDPa lEUSTNITot zlTNITotXllnAidPGDPa) ///
		i.ccode2 i.year902, first vce(cluster ccode2)
	* margins
		margins, at(zllnGBAidTotPGDPWDIa=(-1.5(0.05)2)) dydx(lEUSThUSNoImpDty) vsquish	
	* plot
		marginsplot, addplot(hist zllnGBAidTotPGDPWDIa if zllnGBAidTotPGDPWDIa<2 & zllnGBAidTotPGDPWDIa>-1.5, ///
		yaxis(2) yscale(alt)  xlabel(-1.5 "-1.5 Std.Dev." -1 "-1 Std.Dev." -.5 "-.5 Std.Dev." ///
		-0.02 "Mean" 0.5 "+.5 Std.Dev." 1 "+1 Std.Dev." 1.5 "+1.5 Std.Dev." 2 "+2 Std.Dev.", ///
		labsize(small) alt) ylabel(-1(.5)1.5) color(none) blcolor(black%20)) ///
		level(95) recast(line) plot1opts(lcol(red)) legend(off) ciopt(color(red%30)) recastci(rarea) yline(0)  ///
		xtitle(Log(U.S. Aid as % of Recipient GDP), size(small)) ///
		ytitle("Marginal Effect of Sanctions", size(small)) ///
		title("Average Marginal Effect of Threatened Sanctions on UNGA Vote Dissimilarity", size(small)) 
		gr_edit .yaxis2.title.style.editstyle size(small) editcopy
		gr play "Fig1A.grec"

**# Table D: Threated aid sanctions
	est clear
	* OLS (Columns 1 and 2)
	*Table D: Column 1
	xtreg absidealimportantdiff lEUSThUSAidNoImpDty zllnGBAidTotPGDPWDIa lSanAllNotThTermAid ///
	$cvarl i.year902, fe cluster(ccode2) 
	vif, uncentered
	eststo m1
			
	*Table 1: Column 2
	xtreg absidealimportantdiff c.lEUSThUSAidNoImpDty##c.zllnGBAidTotPGDPWDIa lSanAllNotThTermAid ///
	$cvarl i.year902, fe cluster(ccode2)
	vif, uncentered
	eststo m2

	* Make Table D: (Columns 1 and 2)	
	esttab, bic replace onecell nogap obslast ///
	keep(lEUSThUSAidNoImpDty zllnGBAidTotPGDPWDIa c.lEUSThUSAidNoImpDty#c.zllnGBAidTotPGDPWDIa lSanAllNotThTermAid $cvarl) ///
	order(lEUSThUSAidNoImpDty zllnGBAidTotPGDPWDIa c.lEUSThUSAidNoImpDty#c.zllnGBAidTotPGDPWDIa lSanAllNotThTermAid $cvarl) ///
	star(* .1 ** .05 *** .01) label  b(2) t(2) 
			
	*Table D: Column 2: Reverse Interaction for Interpretation
	xtreg absidealimportantdiff c.lNonTANImp##c.zllnGBAidTotPGDPWDIa lSanAllNotThTermAid ///
	$cvarl i.year902, fe cluster(ccode2)
		
	* 2SLS Model (Columns 3 and 4)
	est clear
	ivreg2 absidealimportantdiff zllnGBAidTotPGDPWDIa lSanAllNotThTermAid $cvarl ///
	(lEUSThUSAidNoImpDty = llEUSThUSAidNoImpDty lEUSTANITot) i.ccode2 i.year902 ///
	, first savefprefix(first) redundant(llEUSThUSAidNoImpDty lEUSTANITot) ///
	endog(lEUSThUSAidNoImpDty) savefirst cluster(ccode2) partial(i.ccode2 i.year902)
	vif, uncentered
	
	* Make Table D: Column 4: Second Stage Results
	esttab, bic replace onecell nogap obslast star(* .1 ** .05 *** .01) label b(2) t(2) 
		
	* Make Table D: Coumn 3: first stage results	
	esttab first*, keep(zllnGBAidTotPGDPWDIa lSanAllNotThTermAid $cvarl lEUSTANITot) ///
	order(zllnGBAidTotPGDPWDIa lSanAllNotThTermAid $cvarl lEUSTANITot) ///
	bic replace onecell nogap obslast star(* .1 ** .05 *** .01) label b(2) t(2)
		
	* 2SLS Interaction Model (Columns 5, 6, 7)
	est clear
	ivreg2 absidealimportantdiff zllnGBAidTotPGDPWDIa lSanAllNotThTermAid $cvarl ///
	(lEUSThUSAidNoImpDty lTANIXzlAidPGDPa = ///
	llEUSThUSAidNoImpDty llTANIXzlAidPGDPa lEUSTANITot zlTANITotXllnAidPGDPa) ///
	i.ccode2 i.year902, first savefprefix(first) ///
	redundant(llEUSThUSAidNoImpDty llTANIXzlAidPGDPa lEUSTANITot zlTANITotXllnAidPGDPa) ///
	endog(lEUSThUSAidNoImpDty lTANIXzlAidPGDPa) savefirst cluster(ccode2) partial(i.ccode2 i.year902)
	vif, uncentered
	eststo
		
	* Make Table D: Column 7: Second Stage Results
		esttab, bic replace onecell nogap obslast ///
		order(lEUSThUSAidNoImpDty zllnGBAidTotPGDPWDIa lTANIXzlAidPGDPa lSanAllNotThTermAid $cvarl) ///
		star(* .1 ** .05 *** .01) label  b(2) t(2)
		
	* Make Table D: Columns 5 and 6: first stage results	
		esttab first*, ///
		keep(zllnGBAidTotPGDPWDIa lSanAllNotThTermAid $cvarl lEUSTANITot zlTANITotXllnAidPGDPa) ///
		order(zllnGBAidTotPGDPWDIa lSanAllNotThTermAid $cvarl lEUSTANITot zlTANITotXllnAidPGDPa) ///
		bic replace onecell nogap obslast ///
		star(* .1 ** .05 *** .01) label  b(2) t(2) 
		
	* Table D: Column 7: Reverse Interaction for Interpretation 
		ivregress 2sls absidealimportantdiff zllnGBAidTotPGDPWDIa lSanAllNotThTermAid $cvarl ///
		(lNonTANImp c.lNonTANImp#c.zllnGBAidTotPGDPWDIa = ///
		llEUSThUSAidNoImpDty llTANIXzlAidPGDPa lEUSTANITot zlTANITotXllnAidPGDPa) ///
		i.ccode2 i.year902, first vce(cluster ccode2)
		
**# Plot Figure C (Threatened Aid Sanctions)
	* Re-estimate 2sls model from columns 5, 6, and 7
		ivregress 2sls absidealimportantdiff zllnGBAidTotPGDPWDIa lSanAllNotThTermAid $cvarl ///
		(lEUSThUSAidNoImpDty c.lEUSThUSAidNoImpDty#c.zllnGBAidTotPGDPWDIa = ///
		llEUSThUSAidNoImpDty llTANIXzlAidPGDPa lEUSTANITot zlTANITotXllnAidPGDPa) ///
		i.ccode2 i.year902, first vce(cluster ccode2)
	* margins
		margins, at(zllnGBAidTotPGDPWDIa=(-1.5(0.05)2)) dydx(lEUSThUSAidNoImpDty) vsquish	
	* plot
		marginsplot, addplot(hist zllnGBAidTotPGDPWDIa if zllnGBAidTotPGDPWDIa<2 & zllnGBAidTotPGDPWDIa>-1.5, ///
		yaxis(2) yscale(alt)  xlabel(-1.5 "-1.5 Std.Dev." -1 "-1 Std.Dev." -.5 "-.5 Std.Dev." ///
		-0.02 "Mean" 0.5 "+.5 Std.Dev." 1 "+1 Std.Dev." 1.5 "+1.5 Std.Dev." 2 "+2 Std.Dev.", ///
		labsize(small) alt) ylabel(-1(.5)1.5) color(none) blcolor(black%20)) ///
		level(95) recast(line) plot1opts(lcol(red)) legend(off) ciopt(color(red%30)) recastci(rarea) yline(0)  ///
		xtitle(Log(U.S. Aid as % of Recipient GDP), size(small)) ///
		ytitle("Marginal Effect of Sanctions", size(small)) ///
		title("Average Marginal Effect of Sanctions on UNGA Vote Dissimilarity", size(small)) 
		gr_edit .yaxis2.title.style.editstyle size(small) editcopy
		gr play "Fig1A.grec"

**# Table E: With minimal controls
	* OLS (Columns 1 and 2)
	est clear
	*Table E: Column 1
	xtreg absidealimportantdiff lEUSimpositionUS zllnGBAidTotPGDPWDIa lEUSThOnly ///
	i.year902, fe cluster(ccode2) 
	eststo m1
	vif, uncentered
		
	*Table E: Column 2
	xtreg absidealimportantdiff c.lEUSimpositionUS##c.zllnGBAidTotPGDPWDIa lEUSThOnly ///
	i.year902, fe cluster(ccode2)
	eststo m2
	vif, uncentered

	* Make Table E: (Columns 1 and 2)	
		esttab, bic replace onecell nogap obslast ///
		keep(lEUSimpositionUS zllnGBAidTotPGDPWDIa c.lEUSimpositionUS#c.zllnGBAidTotPGDPWDIa lEUSThOnly) ///
		order(lEUSimpositionUS zllnGBAidTotPGDPWDIa c.lEUSimpositionUS#c.zllnGBAidTotPGDPWDIa lEUSThOnly) ///
		star(* .1 ** .05 *** .01) label  b(2) t(2) 
		
	*Table E: Column 2: Reverse Interaction for Interpretation
		xtreg absidealimportantdiff c.lNonEUSimpositionUS##c.zllnGBAidTotPGDPWDIa lEUSThOnly ///
		i.year902, fe cluster(ccode2)
	
	* 2SLS Model (Columns 3 and 4)
		est clear
		ivreg2 absidealimportantdiff zllnGBAidTotPGDPWDIa lEUSThOnly  ///
		(lEUSimpositionUS = llEUSimpositionUS lEUSUSTot) i.ccode2 i.year902, ///
		first savefprefix(first) redundant(llEUSimpositionUS lEUSUSTot) ///
		endog(lEUSimpositionUS) savefirst cluster(ccode2) partial(i.ccode2 i.year902) 
		eststo 
		vif, uncentered
							
		* Make Table 1: Column 4: Second Stage Results
			esttab, bic replace onecell nogap obslast ///
			star(* .1 ** .05 *** .01) label b(2) t(2) 
	
		* Make Table 1: Coumn 3: first stage results	
			esttab first*, bic replace onecell nogap obslast ///
			keep(zllnGBAidTotPGDPWDIa lEUSThOnly lEUSUSTot) ///
			order(zllnGBAidTotPGDPWDIa lEUSThOnly lEUSUSTot) ///
			star(* .1 ** .05 *** .01) label  b(2) t(2) 
	
	* 2SLS Interaction Model (Columns 5, 6, 7)
		est clear
		ivreg2 absidealimportantdiff zllnGBAidTotPGDPWDIa lEUSThOnly ///
		(lEUSimpositionUS zlImpUSXllnAidPGDPa = llEUSimpositionUS lzlImpUSXllnAidPGDPa ///
		lEUSUSTot zlEUSUSTotXllnAidPGDPa) i.ccode2 i.year902 , first savefprefix(first) ///
		redundant(llEUSimpositionUS lzlImpUSXllnAidPGDPa lEUSUSTot zlEUSUSTotXllnAidPGDPa) /// 
		endog(lEUSimpositionUS zlImpUSXllnAidPGDPa) savefirst cluster(ccode2) partial(i.ccode2 i.year902)
		eststo
		vif, uncentered
		
		* Make Table E: Column 7: Second Stage Results
			esttab, bic replace onecell nogap obslast ///
			order(lEUSimpositionUS zllnGBAidTotPGDPWDIa zlImpUSXllnAidPGDPa lEUSThOnly) ///
			star(* .1 ** .05 *** .01) label  b(2) t(2) 
		
		* Make Table E: Columns 5 and 6: first stage results	
			esttab first*, bic replace onecell nogap obslast ///
			keep(zllnGBAidTotPGDPWDIa lEUSThOnly zlImpUSXllnAidPGDPa lEUSUSTot zlEUSUSTotXllnAidPGDPa) ///
			order(zllnGBAidTotPGDPWDIa lEUSThOnly zlImpUSXllnAidPGDPa lEUSUSTot zlEUSUSTotXllnAidPGDPa) ///
			star(* .1 ** .05 *** .01) label  b(2) t(2) 
	
	* Table E: Column 7: Reverse Interaction for Interpretation 
		ivregress 2sls absidealimportantdiff zllnGBAidTotPGDPWDIa lEUSThOnly ///
		(lNonEUSimpositionUS c.lNonEUSimpositionUS#c.zllnGBAidTotPGDPWDIa  = llEUSimpositionUS ///
		l.zlImpUSXllnAidPGDPa lEUSUSTot zlEUSUSTotXllnAidPGDPa) ///
		i.ccode2 i.year902, first vce(cluster ccode2) 
		
**# Table F: (2SLS) Interaction With Aid and Sanctions instrumented
	* 2SLS Interaction (Columns 1, 2, 3, 4)	
	est clear
	ivreg2 absidealimportantdiff lEUSThOnly $cvarl  ///
	(lEUSimpositionUS zllnGBAidTotPGDPWDIa zlImpUSXllnAidPGDPa = ///
	llEUSimpositionUS lzlImpUSXllnAidPGDPa lEUSUSTot zlEUSUSTotXllnAidPGDPa ///
	lNatDisTcy lNatDisTXAida) i.ccode2 i.year902 , first savefprefix(first) ///
	redundant(llEUSimpositionUS lzlImpUSXllnAidPGDPa lEUSUSTot zlEUSUSTotXllnAidPGDPa ///
	lNatDisTcy lNatDisTXAida) endog(lEUSimpositionUS zllnGBAidTotPGDPWDIa zlImpUSXllnAidPGDPa) ///
	savefirst cluster(ccode2) partial(i.ccode2 i.year902)
	eststo
	vif, uncentered
	
	* Make Table F: Column 4: Second Stage Results
		esttab, bic replace onecell nogap obslast ///
		order(lEUSimpositionUS zllnGBAidTotPGDPWDIa zlImpUSXllnAidPGDPa lEUSThOnly $cvarl) ///
		star(* .1 ** .05 *** .01) label  b(2) t(2) 
		
	* Make Table 1: Columns 1, 2, 3: first stage results	
		esttab first*, bic replace onecell nogap obslast ///
		keep(lEUSThOnly $cvarl lEUSUSTot zlEUSUSTotXllnAidPGDPa lNatDisTcy lNatDisTXAida) ///
		order(lEUSThOnly $cvarl lEUSUSTot zlEUSUSTotXllnAidPGDPa lNatDisTcy lNatDisTXAida) ///
		star(* .1 ** .05 *** .01) label  b(2) t(2) 
		
	
	* Reverse Interaction for Interpretation (2SLS)
		ivregress 2sls absidealimportantdiff lEUSThOnly $cvarl ///
		(lNonEUSimpositionUS zllnGBAidTotPGDPWDIa c.lNonEUSimpositionUS#c.zllnGBAidTotPGDPWDIa = ///
		llEUSimpositionUS l.zlImpUSXllnAidPGDPa lEUSUSTot zlEUSUSTotXllnAidPGDPa ///
	    lNatDisTcy lNatDisTXAida) i.ccode2 i.year902, first vce(cluster ccode2) 
	
**# Plot Figure D
	* Re-estimate 2sls model from Table F
		ivregress 2sls absidealimportantdiff lEUSThOnly $cvarl  ///
		(lEUSimpositionUS zllnGBAidTotPGDPWDIa c.lEUSimpositionUS##c.zllnGBAidTotPGDPWDIa = ///
		llEUSimpositionUS l.zlImpUSXllnAidPGDPa lEUSUSTot zlEUSUSTotXllnAidPGDPa ///
	    lNatDisTcy lNatDisTXAida) i.ccode2 i.year902 , first vce(cluster ccode2)  
	* margins
		margins, at(zllnGBAidTotPGDPWDIa=(-1.5(0.05)2)) dydx(lEUSimpositionUS) vsquish	
	* plot
		marginsplot, addplot(hist zllnGBAidTotPGDPWDIa if zllnGBAidTotPGDPWDIa<2 & zllnGBAidTotPGDPWDIa>-1.5, ///
		yaxis(2) yscale(alt)  xlabel(-1.5 "-1.5 Std.Dev." -1 "-1 Std.Dev." -.5 "-.5 Std.Dev." ///
		-0.02 "Mean" 0.5 "+.5 Std.Dev." 1 "+1 Std.Dev." 1.5 "+1.5 Std.Dev." 2 "+2 Std.Dev.", ///
		labsize(small) alt) ylabel(-1(.5)1.5) color(none) blcolor(black%20)) ///
		level(95) recast(line) plot1opts(lcol(red)) legend(off) ciopt(color(red%30)) recastci(rarea) yline(0)  ///
		xtitle(Log(U.S. Aid as % of Recipient GDP), size(small)) ///
		ytitle("Marginal Effect of Sanctions", size(small)) ///
		title("Average Marginal Effect of Sanctions on UNGA Vote Dissimilarity", size(small)) 
		gr_edit .yaxis2.title.style.editstyle size(small) editcopy
		gr play "Fig1A.grec"
		
**# Table G: With Linear Time Trend Added
	* OLS (Columns 1 and 2)
	est clear
	*Table G: Column 1
	xtreg absidealimportantdiff lEUSimpositionUS zllnGBAidTotPGDPWDIa lEUSThOnly ///
	$cvartl i.year902, fe cluster(ccode2) 
	eststo m1
	vif, uncentered
		
	*Table G: Column 2
	xtreg absidealimportantdiff c.lEUSimpositionUS##c.zllnGBAidTotPGDPWDIa lEUSThOnly ///
	$cvartl i.year902, fe cluster(ccode2)
	eststo m2
	vif, uncentered
	
	* Make Table G: (Columns 1 and 2)	
		esttab, bic replace onecell nogap obslast ///
		keep(lEUSimpositionUS zllnGBAidTotPGDPWDIa c.lEUSimpositionUS#c.zllnGBAidTotPGDPWDIa lEUSThOnly $cvartl) ///
		order(lEUSimpositionUS zllnGBAidTotPGDPWDIa c.lEUSimpositionUS#c.zllnGBAidTotPGDPWDIa lEUSThOnly $cvartl) ///
		star(* .1 ** .05 *** .01) label  b(2) t(2) 
		
	*Table G: Column 2: Reverse Interaction for Interpretation
		xtreg absidealimportantdiff c.lNonEUSimpositionUS##c.zllnGBAidTotPGDPWDIa lEUSThOnly ///
		$cvartl i.year902, fe cluster(ccode2)
	
	* 2SLS Model (Columns 3 and 4)
		est clear
		ivreg2 absidealimportantdiff zllnGBAidTotPGDPWDIa lEUSThOnly $cvartl ///
		(lEUSimpositionUS = llEUSimpositionUS lEUSUSTot) i.ccode2 i.year902 ///
		,  first savefprefix(first) redundant(llEUSimpositionUS lEUSUSTot) ///
		endog(lEUSimpositionUS) savefirst cluster(ccode2) partial(i.ccode2 i.year902) 
		eststo 
		vif, uncentered

		estat ic
							
		* Make Table G: Column 4: Second Stage Results
			esttab, bic replace onecell nogap obslast star(* .1 ** .05 *** .01) label b(2) t(2) 
	
		* Make Table G: Coumn 3: first stage results	
			esttab first*, bic replace onecell nogap obslast ///
			keep(zllnGBAidTotPGDPWDIa lEUSThOnly $cvartl lEUSUSTot) ///
			order(zllnGBAidTotPGDPWDIa lEUSThOnly $cvartl lEUSUSTot) ///
			star(* .1 ** .05 *** .01) label  b(2) t(2) 
	
	* 2SLS Interaction Model (Columns 5, 6, 7)
		est clear
		ivreg2 absidealimportantdiff zllnGBAidTotPGDPWDIa lEUSThOnly $cvartl  ///
		(lEUSimpositionUS zlImpUSXllnAidPGDPa = llEUSimpositionUS l.zlImpUSXllnAidPGDPa ///
		lEUSUSTot zlEUSUSTotXllnAidPGDPa) i.ccode2 i.year902 , first savefprefix(first) ///
		redundant(llEUSimpositionUS l.zlImpUSXllnAidPGDPa lEUSUSTot zlEUSUSTotXllnAidPGDPa) /// 
		endog(lEUSimpositionUS zlImpUSXllnAidPGDPa) savefirst cluster(ccode2) partial(i.ccode2 i.year902)
		eststo
		vif, uncentered
		
		* Make Table G: Column 7: Second Stage Results
			esttab, bic replace onecell nogap obslast ///
			order(lEUSimpositionUS zllnGBAidTotPGDPWDIa zlImpUSXllnAidPGDPa lEUSThOnly $cvartl) ///
			star(* .1 ** .05 *** .01) label  b(2) t(2) 
		
		* Make Table G: Columns 5 and 6: first stage results	
			esttab first*, bic replace onecell nogap obslast ///
			keep(zllnGBAidTotPGDPWDIa lEUSThOnly $cvartl lEUSUSTot zlEUSUSTotXllnAidPGDPa) ///
			order(zllnGBAidTotPGDPWDIa lEUSThOnly $cvartl lEUSUSTot zlEUSUSTotXllnAidPGDPa) ///
			star(* .1 ** .05 *** .01) label  b(2) t(2) 
		
	* Table G: Column 7: Reverse Interaction for Interpretation 
		ivregress 2sls absidealimportantdiff zllnGBAidTotPGDPWDIa lEUSThOnly $cvartl ///
		(lNonEUSimpositionUS c.lNonEUSimpositionUS#c.zllnGBAidTotPGDPWDIa  = llEUSimpositionUS ///
		l.zlImpUSXllnAidPGDPa lEUSUSTot zlEUSUSTotXllnAidPGDPa) ///
		i.ccode2 i.year902, first vce(cluster ccode2) 	
		
**# Hausman test (mentioned in footnote 11)
	* Table 1: Model 1 (No Interaction) 
	* Random Effects
	est clear
	xtreg absidealimportantdiff lEUSimpositionUS zllnGBAidTotPGDPWDIa lEUSThOnly ///
	$cvarl i.year902,  
	est store random
	
	* Fixed Effects
	xtreg absidealimportantdiff lEUSimpositionUS zllnGBAidTotPGDPWDIa lEUSThOnly ///
	$cvarl i.year902, fe  
	est store fixed

	hausman fixed random, sigmamore
	
	* Table 1: Model 2 (Interaction) 
	* Random Effects
	est clear
	xtreg absidealimportantdiff c.lEUSimpositionUS##c.zllnGBAidTotPGDPWDIa lEUSThOnly ///
	$cvarl i.year902, 
	est store random
	
	* Fixed Effects
	xtreg absidealimportantdiff c.lEUSimpositionUS##c.zllnGBAidTotPGDPWDIa lEUSThOnly ///
	$cvarl i.year902, fe 
	est store fixed

	hausman fixed random, sigmamore
**# End
exit


